package course.d1224;

import java.io.*;

/*
    使用缓冲字符流来完成一个文件的复制
 */
public class p1 {
    public static void main(String[] args) {
        BufferedWriter bw = null;
        BufferedReader br = null;
        BufferedWriter copy = null;
        try {
            bw=new BufferedWriter(new FileWriter("t1.txt"));
            bw.write("天若有情天亦老");
            bw.newLine();
            bw.write("人间正道是沧桑");
            bw.newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (bw!=null){
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        try {
            br = new BufferedReader(new FileReader("t1.txt"));
            String s ;
            while ((s=br.readLine())!=null){
                System.out.println(s);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (br!=null){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
